Demos compléxité
Compléxité temporelle
Soient $\textcolor{#caa7ff}{a}$, $\textcolor{#caa7ff}{b}$, $\textcolor{#caa7ff}{c}$ et $\textcolor{#caa7ff}{d}$ des entiers naturels avec $\textcolor{#caa7ff}{a \ne 0}$ et $\textcolor{#caa7ff}{b \ne 0}$. Considérons les fonctions suivantes :
$$\textcolor{#caa7ff}{
f_{(a,c)} :
\begin{cases}
\mathbb{N} &\to \mathbb{N} \newline
n &\mapsto an + c
\end{cases}
}$$
$$\textcolor{#caa7ff}{
g_{(a,b,c,d)} :
\begin{cases}
\mathbb{N} &\to \mathbb{N} \newline
n &\mapsto a\log_2(bn + c) + d
\end{cases}
}$$
1. Montrer que :
$$\textcolor{#caa7ff}{
\forall (a,c) \in \mathbb{N}^* \times \mathbb{N}, \quad \forall n \in \mathbb{N}, \quad f_{(a,c)}(n) \in \Theta(n)
}$$
2. Montrer que :
$$\textcolor{#caa7ff}{
\forall (a,b,c,d) \in (\mathbb{N}^*)^2 \times \mathbb{N}^2, \quad \forall n \in \mathbb{N}^*, \quad g_{(a,b,c,d)}(n) \in \Theta(\log_2(n))
}$$
1.
Montrons que $\textcolor{#caa7ff}{f}$ est en $\textcolor{#caa7ff}{\Theta(n)}$ :
Pour cela, il faut montrer :
$$\textcolor{#caa7ff}{
\forall (a,c) \in \mathbb{N}^* \times \mathbb{N}, \quad \forall n \in \mathbb{N}
\newline
f_{(a,c)}(n) \in O(n) \quad \text{et} \quad f_{(a,c)}(n) \in \Omega(n)
}$$
C'est a dire :
$$\textcolor{#caa7ff}{
\forall (a,c) \in \mathbb{N}^* \times \mathbb{N}
\newline
\exists (\alpha, N) \in \mathbb{R}^{+*} \times \mathbb{N}, \quad \forall n \in \mathbb{N}, \quad n \ge N \Rightarrow f_{(a,c)}(n) \le \alpha n
\newline
\text{et}
\newline
\exists (\alpha', N') \in \mathbb{R}^{+*} \times \mathbb{N}, \quad \forall n \in \mathbb{N}, \quad n \ge N' \Rightarrow f_{(a,c)}(n) \ge \alpha' n
}$$
Fixons $\textcolor{#caa7ff}{(a,c)}$ dans $\textcolor{#caa7ff}{\mathbb{N}^* \times \mathbb{N}}$
Posons $\textcolor{#caa7ff}{\alpha = a + 1}$ et $\textcolor{#caa7ff}{\alpha' = a}$
Remarquons alors que :
$$\textcolor{#caa7ff}{
\forall n \in \mathbb{N}
\newline
\quad f_{(a,c)}(n) \le \alpha n
\newline \iff
an + c \le (a+1) n
\newline \iff
n \ge c
}$$
et
$$\textcolor{#caa7ff}{
\forall n \in \mathbb{N}
\newline
\quad f_{(a,c)}(n) \ge \alpha' n
\newline \iff
an + c \ge an
\newline \iff
c \ge 0 \quad
\newline
\text{ce qui est toujours vrai car } c \in \mathbb{N}
}$$
Ainsi, en posant $\textcolor{#caa7ff}{N = c}$ et $\textcolor{#caa7ff}{N' = 0}$, on a:
$$\textcolor{#caa7ff}{
\forall n \in \mathbb{N}, \quad n \ge N \Rightarrow f_{(a,c)}(n) \le \alpha n
\newline \text{et} \newline
\forall n \in \mathbb{N}, \quad n \ge N' \Rightarrow f_{(a,c)}(n) \ge \alpha' n
}$$
De plus, on a :
$$\textcolor{#caa7ff}{
(\alpha, \alpha') \in (\mathbb{R}^{+*})^2 \quad \text{et} \quad (N, N') \in \mathbb{N}^2
}$$
Ainsi :
$$\textcolor{#caa7ff}{
\exists (\alpha, N) \in \mathbb{R}^{+*} \times \mathbb{N}, \quad \forall n \in \mathbb{N}, \quad n \ge N \Rightarrow f_{(a,c)}(n) \le \alpha n
}$$
Donc :
$$\textcolor{#caa7ff}{
\exists (\alpha, N) \in \mathbb{R}^{+*} \times \mathbb{N}, \quad \forall n \in \mathbb{N}, \quad n \ge N \Rightarrow f_{(a,c)}(n) \le \alpha n
\newline
\text{et}
\newline
\exists (\alpha', N') \in \mathbb{R}^{+*} \times \mathbb{N}, \quad \forall n \in \mathbb{N}, \quad n \ge N' \Rightarrow f_{(a,c)}(n) \ge \alpha' n
}$$
Et :
$$\textcolor{#caa7ff}{
\forall n \in \mathbb{N}, \quad f_{(a,c)}(n) \in \Theta(n)
}$$
Conclusion :
$\textcolor{#caa7ff}{a}$ et $\textcolor{#caa7ff}{c}$ sont fixés mais quelconques. Ainsi :
$$\textcolor{#caa7ff}{
\boxed{
\forall (a,c) \in \mathbb{N}^* \times \mathbb{N}, \quad \forall n \in \mathbb{N}, \quad f_{(a,c)}(n) \in \Theta(n)
}
}$$
2.
Montrons que $\textcolor{#caa7ff}{g}$ est en $\textcolor{#caa7ff}{\Theta(\log_2(n))}$ :
Pour cela, il faut montrer :
$$\textcolor{#caa7ff}{
\forall (a,b,c,d) \in \mathbb{N}^* \times \mathbb{N}, \quad \forall n \in \mathbb{N}^*
\newline
g_{(a,b,c,d)} \in O(\log_2(n)) \quad \text{et} \quad g_{(a,b,c,d)} \in \Omega(\log_2(n))
}$$
C'est a dire :
$$\textcolor{#caa7ff}{
\forall (a,b,c,d) \in (\mathbb{N}^*)^2 \times \mathbb{N}^2
\newline
\exists (\alpha, N) \in \mathbb{R}^{+*} \times \mathbb{N}, \quad \forall n \in \mathbb{N}^*, \quad n \ge N \Rightarrow g_{(a,b,c,d)}(n) \le \alpha \log_2(n)
\newline
\text{et}
\newline
\exists (\alpha', N') \in \mathbb{R}^{+*} \times \mathbb{N}, \quad \forall n \in \mathbb{N}^*, \quad n \ge N' \Rightarrow g_{(a,b,c,d)}(n) \ge \alpha' \log_2(n)
}$$
Fixons $\textcolor{#caa7ff}{(a,b,c,d)}$ dans $\textcolor{#caa7ff}{(\mathbb{N}^*)^2 \times \mathbb{N}^2}$
Posons $\textcolor{#caa7ff}{\alpha = 2a}$
Remarquons alors que :
$$\textcolor{#caa7ff}{
\forall n \in \mathbb{N}^*
\newline
g_{(a,b,c,d)}(n) \le \alpha \log_2(n)
\newline \iff
a \log_2(bn + c) + d \le \alpha \log_2(n)
\newline \iff
\log_2(bn + c) + \frac{d}{a} \le \frac{2a}{a} \log_2(n)
\newline \iff
\log_2(2^{\frac{d}{a}}(bn + c)) \le 2 \log_2(n)
\newline \iff
2^{\frac{d}{a}}(bn + c) \le n^2
\newline \iff
2^{\frac{d}{a}}bn + 2^{\frac{d}{a}}c \le n^2
\newline \iff
n^2 - 2^{\frac{d}{a}}bn - 2^{\frac{d}{a}}c \ge 0
}$$
Posons $\textcolor{#caa7ff}{P}$ le polynome réel de degré $\textcolor{#caa7ff}{2}$ tel que :
$$\textcolor{#caa7ff}{
\forall x \in \mathbb{R}, \quad P(x) = x^2 - 2^{\frac{d}{a}}bx - 2^{\frac{d}{a}}c
}$$
On a alors :
$$\textcolor{#caa7ff}{
\forall n \in \mathbb{N}^*, \quad g_{(a,b,c,d)}(n) \le \alpha \log_2(n) \iff P(n) \ge 0
}$$
Le coéfficient dominant de $\textcolor{#caa7ff}{P}$ est positif donc :
$$\textcolor{#caa7ff}{
\lim_{x \to +\infty} P(x) = +\infty
}$$
Ainsi, par définition de la limite infinie :
$$\textcolor{#caa7ff}{
\forall m \in \mathbb{R}, \quad \exists x_0 \in \mathbb{R}, \quad \forall x \in \mathbb{R}, \quad x \ge x_0 \Rightarrow P(x) \ge m
}$$
Et, particulièrement :
$$\textcolor{#caa7ff}{
\exists N_0 \in \mathbb{R}, \quad \forall x \in \mathbb{R}, \quad x \ge N_0 \Rightarrow P(x) \ge 0
}$$
Ainsi, en posant $\textcolor{#caa7ff}{N}$ le plus petit entier naturel superieur ou égal à un tel $\textcolor{#caa7ff}{N_0}$, on a :
$$\textcolor{#caa7ff}{
\forall n \in \mathbb{N}^*, \quad n \ge N \Rightarrow P(n) \ge 0
}$$
D'où, par équivalence :
$$\textcolor{#caa7ff}{
\boxed{
\forall n \in \mathbb{N}^*, \quad n \ge N \Rightarrow g_{(a,b,c,d)}(n) \le \alpha \log_2(n)
}
}$$
Posons maintenant $\textcolor{#caa7ff}{\alpha' = a}$
Remarquons alors que :
$$\textcolor{#caa7ff}{
\forall n \in \mathbb{N}^*
\newline
g_{(a,b,c,d)}(n) \ge \alpha' \log_2(n)
\newline \iff
a \log_2(bn + c) + d \ge \alpha' \log_2(n)
\newline \iff
\log_2(bn + c) + \frac{d}{a} \ge \frac{a}{a} \log_2(n)
\newline \iff
\log_2(2^{\frac{d}{a}}(bn + c)) \ge \log_2(n)
\newline \iff
2^{\frac{d}{a}}(bn + c) \ge n
}$$
De plus :
$$\textcolor{#caa7ff}{
\forall n \in \mathbb{N}^*
\newline
bn + c \ge n \quad \text{et} \quad 2^{\frac{d}{a}} \ge 1
}$$
D'où :
$$\textcolor{#caa7ff}{
\forall n \in \mathbb{N}^*, \quad 2^{\frac{d}{a}}(bn + c) \ge n
}$$
Posons $\textcolor{#caa7ff}{N' = 1}$, par équivalence :
$$\textcolor{#caa7ff}{
\boxed{
\forall n \in \mathbb{N}^*, \quad n \ge N' \Rightarrow g_{(a,b,c,d)}(n) \ge \alpha' \log_2(n)
}
}$$
Enfin, on a :
$$\textcolor{#caa7ff}{
\forall n \in \mathbb{N}^*, \quad n \ge N \Rightarrow g_{(a,b,c,d)}(n) \le \alpha \log_2(n)
\newline \text{et} \newline
\forall n \in \mathbb{N}^*, \quad n \ge N' \Rightarrow g_{(a,b,c,d)}(n) \ge \alpha' \log_2(n)
}$$
De plus :
$$\textcolor{#caa7ff}{
(\alpha, \alpha', N, N') \in (\mathbb{R}^{+*})^2 \times \mathbb{N}^2
}$$
Donc :
$$\textcolor{#caa7ff}{
\forall n \in \mathbb{N}^*, \quad g_{(a,b,c,d)}(n) \in \Theta(\log_2(n))
}$$
Conclusion :
$\textcolor{#caa7ff}{a}$, $\textcolor{#caa7ff}{b}$, $\textcolor{#caa7ff}{c}$ et $\textcolor{#caa7ff}{d}$ sont fixés mais quelconques. Ainsi :
$$\textcolor{#caa7ff}{
\boxed{
\forall (a,b,c,d) \in (\mathbb{N}^*)^2 \times \mathbb{N}^2, \quad \forall n \in \mathbb{N}^*, \quad g_{(a,b,c,d)}(n) \in \Theta(\log_2(n))
}
}$$